import com.gl.TestInterface;
import com.gl.User;
import com.gl.anno.AppConfig;
import com.gl.anno.Student;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class Testwww implements gl {


    public static void main(String[] args) {

    }



    @Test
    public void Test(){
        //BeanFactory xmlBeanFactory = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));


      /*  BeanFactory xmlBeanFactory = new ClassPathXmlApplicationContext("applicationContext.xml");
        User user = (User) xmlBeanFactory.getBean("user");
        System.out.println(user.getName());
        System.out.println(user);
        System.out.println(user);

        user.hi();*/


        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
        xmlBeanDefinitionReader.loadBeanDefinitions("applicationContext.xml");
        User user2 = (User) beanFactory.getBean("user");
        System.out.println(user2.getName());
        user2.hi();

    }



    @Test
    public void testAop(){
        BeanFactory xmlBeanFactory = new ClassPathXmlApplicationContext("applicationContext.xml");
        User user = (User) xmlBeanFactory.getBean("user");
        System.out.println(user.getName());
        System.out.println(user);
        System.out.println(user);

        user.hi();
    }


    @Test
    public void gl() {

        BeanFactory f =  new AnnotationConfigApplicationContext(AppConfig.class);
        Student o = (Student) f.getBean("student");
        System.out.println(o);
        o.hi();
        new TestInterface() {
            public void go() {
                System.out.println("go");

            }

            public void ro() {

            }
        }.go();

    }
}
